package com.bachongLightNovel.system.feign;

import com.bachongLightNovel.system.ISystemUserClient;
import com.bachongLightNovel.system.service.SystemUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author vermouth
 */
@RestController
@Slf4j
public class SystemUserClient implements ISystemUserClient{

    @Autowired
    private SystemUserService systemUserService;

    /**
     * @param auditUser
     * @return
     */
    @GetMapping("/api/system/user/feign/get-userId")
    public List<Long> getUserIdByUsername(@RequestParam String auditUser){
        log.info("feign:根据用户名查询用户id：{}",auditUser);
        return systemUserService.getUserIdByUsername(auditUser);
    }


    /**
     * 根据用户id查询用户名
     * @param userId :
     * @return String
     */
    @Override
    @GetMapping("/api/system/user/feign/get-username")
    public String getUsernameById(@RequestParam Long userId) {
        log.info("根据用户id获取用户名");
        return systemUserService.getUserInfo(userId).getUsername();
    }
}
